
package com.probiz.estore.common.model.system;

import org.tuckey.web.filters.urlrewrite.utils.StringUtils;

import com.probiz.estore.common.model.system.base.MailQueueTbl;
import com.probiz.estore.common.util.DateUtil;

/**
 * Model class for MailQueue. Add not database mapped fileds in this class.
 */
public class MailQueue extends MailQueueTbl {


	public final static short	STATUS_NOT_SEND		= 0;  //等待发送

	public final static short	STATUS_SENDING		= 1;  //发送中

	public final static short	STATUS_SENT			= 2;  //已发送

	public final static short	STATUS_CANCELLED	= 9;  //取消发送
	/**
	 * Default Empty Constructor for class MailQueue
	 */
	public MailQueue() {
		super();
		sendStatus = 0;
		sendTimes = 0;
		errorMsg = "";
	}

	/**
	 * Default Key Fields Constructor for class MailQueue
	 */
	public MailQueue(Integer in_mailQueueId) {
		super(in_mailQueueId);
	}

	public void appendErrorMsg(String errMsg) {
		StringBuilder sb = new StringBuilder(errorMsg);
		sb.append(DateUtil.getNowStr()).append(" - ");
		if(!StringUtils.isBlank(errMsg)){
			sb.append(errMsg);
		}
		sb.append("<br/>");
		String result = sb.toString();
		if (sb.length() > 1024)
		{
			int len = sb.length();
			result = sb.substring(len - 1024, sb.length());
		}
		errorMsg = result;
	}
}
